#include<iostream>
const int N = 1000;
int arr1[N][N],arr2[N][N];
using namespace std;
int main(){
	int n,m,r = 0,count = 0;
	cin >> m >> n;
	for(int i = 0; i < m; i++){
		for(int j = 0; j < n; j++){
			cin >> arr1[i][j];
		}	
	}
	for(int i = 0; i < m; i++){
		for(int j = 0; j < n; j++){
			cin >> arr2[i][j];
			if(arr1[i][j] == arr2[i][j]) count++;
		}
	}
	printf("%.2lf",1.0 * count/ (m * n)* 100 );

	return 0;
}
